import bcrypt


def encrypt(passwd):
  """字符加密"""
  return bcrypt.hashpw(bytes(passwd, encoding = "utf8"), bcrypt.gensalt(10))


def decrypt(passwd, hashed):
  """校验明文"""
  return bcrypt.checkpw(bytes(passwd, encoding = "utf8"), bytes(hashed, encoding = "utf8"))